program meanfreepath
	integer, dimension(12) 						:: seed  
	real, allocatable, dimension(:)  	:: x, y
	real															:: k = 0.7
	real		:: sumx, sumy
  integer :: n
  integer :: i, j
  call system_clock(seed(1))
  call random_seed(put=seed)
  read*,n
	allocate(x(n))
	allocate(y(n))
	sumx = 0
	sumy = 0 
do k = 0.05, 10, 0.01	
	do i = 1,n
		call random_number(x(i))
		x(i) = x(i)/k
		y(i) = g(x(i))
		sumx = x(i)*y(i) + sumx
		sumy = y(i) + sumy
		!print*, x(i), y(i)
	end do
	write(*,*), k, sumx/sumy
end do
 contains
 
	real function g(x)
	 	real, intent(in) :: x
	 	g = 1.0/k*exp(-1.0*x/k) !exp(-1*y*y)/sqrt(3.141)
 end function

end program
